Web Scraping for Comments

by: MitchBCrich, 7 years ago


Hey,

I want to be able to pull out comments from html using BeautifulSoup but I can't seem to get it to work.
I've tried soup.find_all('<!--') but all it gives me is an empty list. Any help getting this to work would be great!

Here is the code that I'm using:


import bs4 as bs
import urllib.request

source = urllib.request.urlopen('http://www.pythonchallenge.com/pc/def/ocr.html').read()

soup = bs.BeautifulSoup(source, 'lxml')

print(soup.find_all('<!--'))


Thanks,
Mitchell



You must be logged in to post. Please login or register an account.